package main

import (
	"fmt"
	"net/http"

	"chix/handle"

	"github.com/go-chi/chi/v5"
)

func main() {
	app := chi.NewRouter()
	routers(app)
	for _, route := range app.Routes() {
		showRoutes("", route)
	}
	http.ListenAndServe(":8080", app)
}

func showRoutes(pattern string, route chi.Route) {
	for s, _ := range route.Handlers {
		fmt.Printf("%s->%s->%s\n", pattern, route.Pattern, s)
	}
	if route.SubRoutes != nil {
		for _, r := range route.SubRoutes.Routes() {
			showRoutes(route.Pattern, r)
		}
	}
}

func routers(app *chi.Mux) {
	app.Group(func(r chi.Router) {
		r.Route("/", func(r chi.Router) {
			handle.Resp{}.InitRoute(r)
			handle.Req{}.InitRoute(r)
		})
	})
}
